package com.company.cloud.club.modules.db.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.company.cloud.club.modules.utils.IdGenerator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

/**
 * *****************************************************************************
 * <p>
 * 功能名           ：com.company.cloud.club.app.db.domain
 * 系统名           ：
 * <p>
 * *****************************************************************************
 * Modification History
 * <p>
 * Date        Name                    Reason for Change
 * ----------  ----------------------  -----------------------------------------
 * 2020/6/12     zhangxu                 Created
 */
@Getter
@Setter
public class BaseEntity<T extends Model> {

    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.ID_WORKER_STR)
    private String id;

    @TableField("time_created")
    @JsonIgnore
    private Long timeCreated;

    @TableField("time_modified")
    @JsonIgnore
    private Long timeModified;

    /**
     * 删除状态：0->未删除；1->已删除
     */
    @JsonIgnore
    private Integer deleted;

    @TableField(exist = false)
    @JsonIgnore
    private Integer currentPage = 1;

    @TableField(exist = false)
    @JsonIgnore
    private Integer pageSize = 10;

    public BaseEntity() {

    }

    public BaseEntity(Integer deleted) {
        setId(IdGenerator.getIdStr());
        setDeleted(deleted);
        setTimeCreated(System.currentTimeMillis());
        setTimeModified(System.currentTimeMillis());
    }

}